/** 枚举 */

import type { OptionsRow, OptionsType } from "plus-pro-components";

/**
 * 菜单类型（文本）
 */
export enum MenuTypeText {
  menu = "菜单",
  iframe = "iFrame",
  link = "链接",
  button = "按钮"
}

/**
 * 根据菜单中文名获取TagType
 *
 * @param typeChineseName 中文名称
 * @param defaultValue 默认类型
 * @returns
 */
export const getMenuTagType = (
  typeChineseName: string,
  defaultValue = "info"
) => {
  for (const key in MenuTypeText) {
    if (MenuTypeText[key] === typeChineseName) {
      switch (key) {
        case "menu":
          return "primary";
        case "iframe":
          return "warning";
        case "link":
          return "danger";
        case "button":
          return "info";
      }
    }
  }
  return defaultValue;
};

/**
 * 获取菜单类型提示文本
 *
 * @param type 类型
 * @returns
 */
export const getMenuTypeTips = (type: string) => {
  switch (type) {
    case "menu":
      return "每个菜单对应一个唯一的页面";
    case "iframe":
      return "iframe菜单为内嵌iFrame页面，需要输入一个可访问的链接地址";
    case "link":
      return "链接菜单点击后将会自动跳转到对应的链接地址";
    case "button":
      return "按钮菜单可以控制按钮级的权限";
  }
};

/**
 * 获取菜单类型选项
 *
 * @returns
 */
export const getMenuTypeOptions = (): OptionsType => {
  const options: OptionsRow[] = [];
  for (const index in MenuTypeText) {
    options.push({
      label: MenuTypeText[index],
      value: index
    });
  }
  return options;
};
